import requests
sess  = requests.session()
ip = "192.168.1.59"

# 文件表单上传
def file_upload():
    # 传入文件路径
    path = "D:\\snick.jpeg"
    # 打开文件 并传入files 变量中
    with open(path,"rb") as f:
        # file是fiddler抓包中name属性的值
        files = {"file":(path,f)}
        # 文件上传
        rp = sess.request("post","http://"+ip+":8080/pinter/file/api/upload",files=files)
    print(rp.text)
# 文件ajax上传
def file_Ajax():
    # 传入文件路径
    path = "D:\\snick.jpeg"
    # 打开文件 并传入files 变量中
    with open(path,"rb") as f:
        # file是fiddler抓包中name属性的值
        files = {"file":(path,f)}
        # 文件上传
        rp = sess.request("post","http://"+ip+":8080/pinter/file/api/upload2",files=files)
    print(rp.text)
# 文件下载
def file_get():
    # 传入下载文件的编号
    params = {"id":1}
    # 文件下载
    rp = sess.request("get","http://"+ip+":8080/pinter/file/api/download",params=params)
    print(rp.text)
if __name__ == '__main__':
    file_upload()
    file_Ajax()
    file_get()